package com.test;

import org.taptwo.android.widget.ViewFlow;

import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
	private ViewFlow viewFlow;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Button btn=(Button) findViewById(R.id.button1);
		btn.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				starteoeMarket();
				
			}
		});
	}
	
	 protected void starteoeMarket() {
         // eoeMarket package
         String eoemarket_package = "com.eoeandroid.market";
         // the search activity
         String eoemarket_search_act = "com.eoeandroid.market.ui.OnSearchActivity";
         // the url for download the lastest eoemarket.apk file
         String download_apk = "http://www.eoemarket.com/download/latest_eoemarket_client.apk";

         try {
                 PackageManager packageManager = getPackageManager();
                 packageManager.getApplicationInfo(eoemarket_package, 0);
                 // this is your app's keywords(package)
                 String package_str = "com.nubinews.chinareader";
                 // new a Intent to launch eoemarket and search your app's
                 Intent intent = new Intent(Intent.ACTION_SEARCH);
                 intent.putExtra(SearchManager.QUERY, package_str);
                 // 下面是eoeMarket的包名和调用的Activity名
                 intent.setClassName(eoemarket_package, eoemarket_search_act);
                 startActivity(intent);
         } catch (NameNotFoundException e) {
                 // if the device is not install eoemarket,download it.
                 Uri uri = Uri.parse(download_apk);
                 Intent it = new Intent(Intent.ACTION_VIEW, uri);
                 startActivity(it);
         }

 }
}